home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / gfx / x11 / x3270_3_2_16.lha / amiga_src / Husk.c < prev    next >
C/C++ Source or Header  |  2001-06-23  |  4KB  |  154 lines

  1. /*
  2.  * Copyright 1996, 1999 by Paul Mattes.
  3.  *  Permission to use, copy, modify, and distribute this software and its
  4.  *  documentation for any purpose and without fee is hereby granted,
  5.  *  provided that the above copyright notice appear in all copies and that
  6.  *  both that copyright notice and this permission notice appear in
  7.  *  supporting documentation.
  8.  */
  9.  
  10. /*
  11.  * Husk.c - Husk composite widget
  12.  *    A "Husk" (a nearly useless shell) is a trivial container widget, a
  13.  *    subclass of the Athena Composite widget with a no-op geometry manager
  14.  *    that allows children to move and resize themselves at will.
  15.  */
  16.  
  17. #include "globals.h"
  18. #include <X11/IntrinsicP.h>
  19. #include <X11/StringDefs.h>
  20. #include <X11/Xmu/Misc.h>
  21. #include <X11/Xaw/XawInit.h>
  22. #include "HuskP.h"
  23.  
  24. static void ClassInitialize(void);
  25. static void Initialize(Widget, Widget, ArgList, Cardinal *);
  26. static void Realize(register Widget, Mask *, XSetWindowAttributes *);
  27. static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal *);
  28. static XtGeometryResult GeometryManager(Widget, XtWidgetGeometry *,
  29.     XtWidgetGeometry *);
  30. static void ChangeManaged(Widget);
  31. static XtGeometryResult QueryGeometry(Widget, XtWidgetGeometry *,
  32.     XtWidgetGeometry *);
  33.  
  34. HuskClassRec huskClassRec = {
  35.     { /* core_class fields      */
  36.     /* superclass         */ (WidgetClass) 0,
  37.     /* class_name         */ "Husk",
  38.     /* widget_size        */ sizeof(HuskRec),
  39.     /* class_initialize   */ ClassInitialize,
  40.     /* class_part_init    */ NULL,
  41.     /* class_inited       */ FALSE,
  42.     /* initialize         */ Initialize,
  43.     /* initialize_hook    */ NULL,
  44.     /* realize            */ Realize,
  45.     /* actions            */ NULL,
  46.     /* num_actions          */ 0,
  47.     /* resources          */ NULL,
  48.     /* num_resources      */ 0,
  49.     /* xrm_class          */ NULLQUARK,
  50.     /* compress_motion    */ TRUE,
  51.     /* compress_exposure  */ TRUE,
  52.     /* compress_enterleave */ TRUE,
  53.     /* visible_interest   */ FALSE,
  54.     /* destroy            */ NULL,
  55.     /* resize             */ NULL,
  56.     /* expose             */ NULL,
  57.     /* set_values         */ SetValues,
  58.     /* set_values_hook    */ NULL,
  59.     /* set_values_almost  */ 0,
  60.     /* get_values_hook    */ NULL,
  61.     /* accept_focus       */ NULL,
  62.     /* version            */ XtVersion,
  63.     /* callback_private   */ NULL,
  64.     /* tm_table           */ NULL,
  65.     /* query_geometry     */ QueryGeometry,
  66.     /* display_accelerator */ 0,
  67.     /* extension          */ NULL
  68.     }, {
  69.     /* composite_class fields */
  70.     /* geometry_manager   */ GeometryManager,
  71.     /* change_managed     */ ChangeManaged,
  72.     /* insert_child          */ 0,
  73.     /* delete_child          */ 0,
  74.     /* extension          */ NULL
  75.     }, {
  76.     /* Husk class fields */
  77.     /* empty          */ 0,
  78.     }
  79. };
  80.  
  81. WidgetClass huskWidgetClass = (WidgetClass)&huskClassRec;
  82.  
  83. #ifdef AMIGA
  84. void AMIGA_INIT_HUSK(void)
  85.  {
  86.  huskClassRec.superclass=compositeWidgetClass;
  87.  huskClassRec.set_values_almost=XtInheritSetValuesAlmost;
  88.  huskClassRec.display_accelerator=XtInheritDisplayAccelerator;
  89.  huskClassRec.insert_child=XtInheritInsertChild;
  90.  huskClassRec.delete_child=XtInheritDeleteChild;
  91.  }
  92. #endif
  93.  
  94. static XtGeometryResult 
  95. QueryGeometry(Widget widget unused, XtWidgetGeometry *constraint unused,
  96.     XtWidgetGeometry *preferred unused)
  97. {
  98.     return XtGeometryYes;
  99. }
  100.  
  101. static XtGeometryResult 
  102. GeometryManager(Widget w, XtWidgetGeometry *request,
  103.     XtWidgetGeometry *reply unused)
  104. {
  105.     /* Always succeed. */
  106.     if (!(request->request_mode & XtCWQueryOnly)) {
  107.         if (request->request_mode & CWX)
  108.             w->core.x = request->x;
  109.         if (request->request_mode & CWY)
  110.             w->core.y = request->y;
  111.         if (request->request_mode & CWWidth)
  112.             w->core.width = request->width;
  113.         if (request->request_mode & CWHeight)
  114.             w->core.height = request->height;
  115.         if (request->request_mode & CWBorderWidth)
  116.             w->core.border_width = request->border_width;
  117.     }
  118.     return XtGeometryYes;
  119. }
  120.  
  121. static void 
  122. ChangeManaged(Widget w unused)
  123. {
  124. }
  125.  
  126. static void 
  127. ClassInitialize(void)
  128. {
  129.     XawInitializeWidgetSet();
  130. }
  131.  
  132. static void 
  133. Initialize(Widget request unused, Widget new unused, ArgList args unused,
  134.     Cardinal *num_args unused)
  135. {
  136. }
  137.  
  138. static void 
  139. Realize(register Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
  140. {
  141.     attributes->bit_gravity = NorthWestGravity;
  142.     *valueMask |= CWBitGravity;
  143.  
  144.     XtCreateWindow(w, (unsigned)InputOutput, (Visual *)CopyFromParent,
  145.            *valueMask, attributes);
  146. }
  147.  
  148. static Boolean 
  149. SetValues(Widget current unused, Widget request unused, Widget new unused,
  150.     ArgList args unused, Cardinal *num_args unused)
  151. {
  152.     return False;
  153. }
  154.